<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2016-11-28
 * Time: 14:31
 */

namespace app\src\alibaichuan\service;


class OpenImRelationsGetService extends BaseAlibaichuanService
{
    /**
     * @param $uid string 百川的用户id
     * @param $beginDate string 20160203
     * @param $endDate   string 20160203
     * @return array
     * @throws \Exception
     */
    public function getRelations($uid,$beginDate,$endDate){
        $topClient = $this->getTopClient();
        $req = new \OpenimRelationsGetRequest();
        $user = new \OpenImUser();
        $req->setBegDate($beginDate);
        $req->setEndDate($endDate);
        
        $user->uid = $uid;
//        $user->taobao_account="false";
//        $user->app_key=$this->getAppKey();

        $req->setUser(json_encode($user));
        $resp = $topClient->execute($req);
        $parseResp = $this->parseResp($resp);
        if($parseResp['code'] === "0"){

            $extra = $parseResp['extra'];
            $users = $extra['users'];

            //正确
            return ['status'=>true,'info'=>$users ];

        }else{
            //错误
            return ['status'=>false,'info'=>$parseResp['info'],'extra'=>$parseResp];
        }
    }

}